

$(function () {
    $('.img-btn').click(function (event) {
        var self = $(this);
        var dialog = $('#img-dialog');

        var tr = self.parent().parent();
        var trad_img = tr.attr("data-img");
        var image = $('#img-id');
        // console.log(trad_img);
        image.attr('src', trad_img);
        dialog.modal('show');
    })
});


$(function() {

		$('table th input:checkbox').on(
				'click',
				function() {
					var self = this;
					$(this).closest('table').find(
							'tr > td:first-child input:checkbox').each(
							function() {
								this.checked = self.checked;
								$(this).closest('tr').toggleClass('selected');
							});
				});
	});




$(function () {
    $('#save-logo-btn').click(function (event) {
        event.preventDefault();
        var self = $(this);
        var dialog = $('#banner-dialog');
        var big_img = $("input[name='big_img']").val();
        var small_img = $("input[name='small_img']").val();

        var url = '/cms/update_logo/';

        zlajax.post({
            'url':url,
            'data':{
                'big_img':big_img,
                'small_img':small_img,
            },
            'success':function (data) {
                dialog.modal('hide');
                if(data['code']==200){
                    window.location.reload()
                }else{
                    zlalert.alertInfo(data['message']);
                }
            },
            'fail':function () {
                zlalert.alertNetworkError();
            }
        })
    })
});



